package com.lovoerp.util;

import java.util.List;

public class PageUtil<T> {
    private List<T> data;
    private int pageNo;
    private int pageSize;
    private int count;
    private int totalPage;

    public PageUtil() {
    }

    public PageUtil(List<T> data, int pageNo, int pageSize, int count) {
        this.data = data;
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.count = count;
        this.totalPage = (count % pageSize == 0) ? (count / pageSize) : (count / pageSize + 1);
    }

    public boolean hasNextPage(){
        if(pageNo  < totalPage) {
            return true;
        }
        else{
            return false;
        }
    }

    public boolean hasPrevPage(){
        if(pageNo > 1){
            return true;
        }
        else{
            return false;
        }
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
}
